﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.util {
    import Engine.Classes.*;
    import Engine.Managers.*;
    import flash.media.*;

    public class SoundObjectWrapper {

        private var m_soundObject:SoundObject = null;
        private var m_isPaused:Boolean;
        private var m_isLoaded:Boolean;
        private var m_url:String;
        private var m_id:String;
        private var m_startTime:Number;
        private var m_loops:int;
        private var m_transform:SoundTransform;
        private var m_isMusic:Boolean;
        private var m_lazyLoad:Boolean;

        public function SoundObjectWrapper(_arg1:String, _arg2:String, _arg3:Boolean=false){
            var onLoadComplete:* = null;
            var id:* = _arg1;
            var url:* = _arg2;
            var lazyLoad:Boolean = _arg3;
            super();
            this.m_id = id;
            this.m_url = url;
            this.m_lazyLoad = lazyLoad;
            this.m_isPaused = true;
            this.m_isLoaded = false;
            if (!this.m_lazyLoad){
                onLoadComplete = function ():void{
                    m_isLoaded = true;
                    if ((((m_soundObject == null)) && (!(m_isPaused)))){
                        unpause();
                    };
                };
                SoundManager.addSound(this.m_id, this.m_url, false, onLoadComplete);
            };
        }
        public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null, _arg4:Boolean=false):void{
            var onLoadComplete:* = null;
            var startTime:Number = _arg1;
            var loops:int = _arg2;
            var transform = _arg3;
            var isMusic:Boolean = _arg4;
            this.m_startTime = startTime;
            this.m_loops = loops;
            this.m_transform = transform;
            this.m_isMusic = isMusic;
            this.m_isPaused = false;
            if (this.m_lazyLoad){
                onLoadComplete = function ():void{
                    m_isLoaded = true;
                    if (!m_isPaused){
                        unpause();
                    };
                };
                SoundManager.addSound(this.m_id, this.m_url, false, onLoadComplete);
            } else {
                this.m_soundObject = SoundManager.playSound(this.m_id, this.m_startTime, this.m_loops, this.m_transform, this.m_isMusic);
            };
        }
        public function isPlaying():Boolean{
            if (this.m_soundObject != null){
                return (this.m_soundObject.isPlaying());
            };
            return (!(this.m_isPaused));
        }
        public function pause():void{
            if (this.m_soundObject != null){
                this.m_soundObject.pause();
            } else {
                this.m_isPaused = true;
            };
        }
        public function unpause():void{
            if (this.m_soundObject != null){
                this.m_soundObject.unpause();
            } else {
                if (this.m_isLoaded){
                    this.m_soundObject = SoundManager.playSound(this.m_id, this.m_startTime, this.m_loops, this.m_transform, this.m_isMusic);
                } else {
                    this.m_isPaused = false;
                };
            };
        }

    }
}//package Classes.util 
